package org.jeecg.modules.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import org.apache.commons.collections.CollectionUtils;
import org.jeecg.modules.assets.api.AssetsServiceApi;
import org.jeecg.modules.assets.entity.DeptExt;
import org.jeecg.modules.assets.service.IDeptExtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssetsServiceApiImpl implements AssetsServiceApi {

    @Autowired
    private IDeptExtService ideptExtService;

    @Override
    public boolean isLeader(String id) {
        LambdaQueryWrapper<DeptExt> lambda = new QueryWrapper<DeptExt>().lambda();
        lambda.eq(DeptExt::getDeptUserId, id).or().eq(DeptExt::getAssetsUserId, id);
        List<DeptExt> list = ideptExtService.list(lambda);
        if (CollectionUtils.isNotEmpty(list)) {
            return true;
        } else {
            return false;
        }
    }
}
